﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Irvin_Engine.Input
{
    public class InputManager
    {
       /* #region Interface IUpdateable
        bool enabled;
        public bool Enabled { get { return enabled; } }

        int updateOrder = 0;
        public int UpdateOrder {get {return updateOrder;}}

        
        #endregion*/

        KeyboardState oldState;

        GamePadState oldPadState;


        public InputManager()
        {
            oldState = Keyboard.GetState();
            oldPadState = GamePad.GetState(PlayerIndex.One);
        }

        bool IsNewKeyPressed(Keys _key)
        {
            KeyboardState newState = Keyboard.GetState();
            if(newState.IsKeyDown(_key))
            {
                if(!oldState.IsKeyDown(_key))
                {
                    oldState = newState;
                    return true;
                }
                oldState = newState;
            }
            return false;
        }

        bool IsNewButtonPressed(Buttons _button, PlayerIndex _indexPlayer)
        {
            GamePadState newButton = GamePad.GetState(_indexPlayer);
            if (newButton.IsButtonDown(_button))
            {
                if (!oldPadState.IsButtonDown(_button))
                {
                    oldPadState = newButton;
                    return true;
                }
                oldPadState = newButton;
            }
            return false;
        }

        public void Update(GameTime gameTime)
        {
            
        }
    }
}
